<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>动态组件</title>
</head>
<body>
  <div id="app">
    <!-- <home></home>
    <kind></kind>
    <cart></cart>
    <user></user> -->
    <!-- <component is="Home"></component>
    <component is="Kind"></component>
    <component is="Cart"></component>
    <component is="User"></component> -->

    <button @click="currentTab = 'Home'">首页</button>
    <button @click="currentTab = 'Kind'">分类</button>
    <button @click="currentTab = 'Cart'">购物车</button>
    <button @click="currentTab = 'User'">我的</button>

    <component :is="currentTab"></component>
  </div>
</body>
<script src="../lib/vue.global.js"></script>
<script>
  const Home = {
    template: `
      <div>
        首页
      </div>
    `
  }
  const Kind = {
    template: `
      <div>
        分类
      </div>
    `
  }
  const Cart = {
    template: `
      <div>
        购物车
      </div>
    `
  }
  const User = {
    template: `
      <div>
        我的
      </div>
    `
  }
  Vue.createApp({
    data () {
      return {
        currentTab: 'Home'
      }
    },
    components: {
      Home,
      Kind,
      Cart,
      User
    }
  }).mount('#app')
</script>
</html>